using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class BootStart : MonoBehaviour
{
    public Image imgMail;
    public Image imgMailSystem;
    public Image imgMailTeam;
    public Image imgMailAlliance;

    public Text txtMail;
    public Text txtMailSystem;
    public Text txtMailTeam;
    public Text txtMailAlliance;

    public Button butMailSystem;
    public Button butMailTeam;
    public Button butMailAlliance;
    // Start is called before the first frame update
    void Start()
    {
        RedPointSystem rps = new RedPointSystem();
        rps.InitRedPointTreeNode();

        rps.SetRedPointNodeCallBack(RedPointConst.mail, MailCallBack);
        rps.SetRedPointNodeCallBack(RedPointConst.mailSystem, MailSystemCallBack);
        rps.SetRedPointNodeCallBack(RedPointConst.mailTeam, MailTeamCallBack);
        rps.SetRedPointNodeCallBack(RedPointConst.mailAlliance, MailAllianceCallBack);

        rps.SetInvoke(RedPointConst.mailSystem, 3);
        rps.SetInvoke(RedPointConst.mailTeam, 2);
        rps.SetInvoke(RedPointConst.mailAlliance, 1);

        butMailSystem.onClick.AddListener(() =>
        {
            rps.SetInvoke(RedPointConst.mailSystem, 0);
        });
        butMailTeam.onClick.AddListener(() =>
        {
            rps.SetInvoke(RedPointConst.mailTeam, 0);
        });
        butMailAlliance.onClick.AddListener(() =>
        {
            rps.SetInvoke(RedPointConst.mailAlliance, 0);
        });
    }

    private void MailAllianceCallBack(RedPointNode node)
    {
        txtMailAlliance.text = node.pointNum.ToString();
        imgMailAlliance.gameObject.SetActive(node.pointNum > 0);
    }

    private void MailTeamCallBack(RedPointNode node)
    {
        txtMailTeam.text = node.pointNum.ToString();
        imgMailTeam.gameObject.SetActive(node.pointNum > 0);
    }

    private void MailSystemCallBack(RedPointNode node)
    {
        txtMailSystem.text = node.pointNum.ToString();
        imgMailSystem.gameObject.SetActive(node.pointNum > 0);
    }

    private void MailCallBack(RedPointNode node)
    {
        txtMail.text = node.pointNum.ToString();
        imgMail.gameObject.SetActive(node.pointNum > 0);
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
